/*
 * @Descripttion: 
 * @version: 
 * @Author: wangzhilei
 * @Date: 2021-10-06 05:41:31
 * @LastEditors: wangzhilei
 * @LastEditTime: 2021-10-06 06:51:42
 */
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>

void myHandler(int sig);

int main(int argc,char *argv[])
{
    struct sigaction act,oact;

    act.sa_handler=myHandler;
    sigemptyset(&act.sa_mask);
    act.sa_flags=0;
    sigaction(SIGINT,&act,&oact);
    sigaddset(&act.sa_mask,SIGINT);
    while (1)
    {
        printf("hello\n");
        pause();//信号会打断阻塞
    }
    return 0;
}
void myHandler(int sig)
{
    printf("i got signal: %d\n",sig);
}